package com.sta.oldman.config;


import jakarta.servlet.http.HttpSession;

import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;

/**
 * @author: LunBoWang
 * @description: 获取httpSession配置类
 * @date: 2025/7/15 下午8:47
 * @version: 1.0
 */

public class GetHttpSessionConfig extends ServerEndpointConfig.Configurator {
    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
        //获取HttpSession
        HttpSession httpSession = (HttpSession) request.getHttpSession();
        //将HttpSession存入到EndpointConfig中
        sec.getUserProperties().put(HttpSession.class.getName(), httpSession);
    }
}
